package org.cnsoft.player.service;

import javax.annotation.Resource;

import org.cnsoft.framework.beans.common.RESTResultBean;
import org.cnsoft.framework.beans.user.LoginerBean;
import org.cnsoft.framework.support.MyServiceSupport;
import org.cnsoft.framework.utils.DateHelper;
import org.cnsoft.framework.weixin.bean.WxCallBackParamBean;
import org.cnsoft.player.ISPLayerRegistService;
import org.cnsoft.player.ISPlayerCheckService;
import org.springframework.stereotype.Service;

import com.cnsoft.persistent.player.U101010PlayerInfo.U101010PlayerInfoDao;
import com.cnsoft.persistent.player.U101112PlayerWeixin.U101112PlayerWeixinDBO;
import com.cnsoft.persistent.player.U101112PlayerWeixin.U101112PlayerWeixinDao;

/**
 * 超管菜单权限
 * 
 * @author ZmSoft
 * @version 0.1.0 2018/3/1
 * @since 0.1.0 2018/3/1
 */
@Service("AppPLayerRegistService")
// @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PLayerRegistService extends MyServiceSupport implements ISPLayerRegistService {
	
	@Resource
	private U101112PlayerWeixinDao daoU101112PlayerWeixin;
	
	ISPlayerCheckService myPlayerCheckService;
	@Resource
	private U101010PlayerInfoDao daoU101010PlayerInfo;

	public RESTResultBean<String> doRegist(LoginerBean loginer) throws Exception {
		RESTResultBean<String> result = new RESTResultBean<String>();
//			U101012PlayerPassportDBO paramPassport = new U101012PlayerPassportDBO();
//			paramPassport.makePrimarykey();
//			paramPassport.setAccount(loginer.getAccount());
//			paramPassport.setPassWord(loginer.getPassWord());
//			daoU101012PlayerPassport.doInsert(paramPassport);

//			U101010PlayerInfoDBO paramInfo = new U101010PlayerInfoDBO();
//			paramInfo.setId(paramPassport.getId());// 手机号作为账户
//			paramInfo.setUserPhone(loginer.getAccount());
//			daoU101010PlayerInfo.doInsert(paramPassport);
			
			

			//param.setSubscribeTime(DateHelper.currentTimeMillisCN1());
			// 创建新微信用户
//			daoU101112PlayerWeixin.doInsert(param);
//			// 微信登录用户的场合直接创建新用户
//			P611010PlayerAuthDBO player = new P611010PlayerAuthDBO();
//			player.setId(param.getId());
//			daoP611010PlayerAuth.doInsert(player);
		return result;
	}

	/**
	 * 微信登录的场合自动创建
	 * @see <PlayerCheckService>
	 */
	@Override
	public RESTResultBean<String> doRegist(WxCallBackParamBean wxUserBean) throws Exception {

		RESTResultBean<String> result = new RESTResultBean<String>();

		// 创建新微信用户
		U101112PlayerWeixinDBO weixinUser = new U101112PlayerWeixinDBO();
		weixinUser.setWxOpenId(wxUserBean.getOpenid());
		weixinUser.setNickName("微信用户");
		weixinUser.setSubscribeTime(DateHelper.currentTimeMillisCN1());
		daoU101112PlayerWeixin.doInsert(weixinUser, 1, false);
		
		//数据更新在check下面，这里只做基本操作
		result.setData(weixinUser);
		
		return result;
	}


}
